<template>
    <div>
        <h3>手写</h3>
    </div>
</template>
<script>
export default {
    data(){
        return{
            permute:undefined
        }
    },
    mounted(){
        this.permutation()
    },
    methods:{
        // 排列组合
       permutation(){
    let  permute = (string) => {
    const result = []
    const map = new Map()
    const dfs = (path) => {
            if (path.length === string.length) {
            result.push(path)
            return
            }
            for (let i = 0; i < string.length; i++) {
            if (map.get(string[i])) continue
            map.set(string[i], true)
            path += string[i]
            dfs(path)
            path = path.substring(0, path.length - 1)
            map.set(string[i], false)
            }
        }
        dfs('')
        return result
        }
     console.log(permute('abc')) // [ 'abc', 'acb', 'bac', 'bca', 'cab', 'cba' ]
       } 
    }
}
</script>